#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int maxTurbulenceSize(vector<int>&& arr) {
    int n = arr.size();
    int len = 1;
    vector<int> f(n + 10, 1);
    vector<int> g(n + 10, 1);

    for (int i = 2; i <= n; ++i)
    {
        int a = arr[i - 2], b = arr[i - 1];

        f[i] = a < b ? g[i - 1] + 1 : 1;
        g[i] = a > b ? f[i - 1] + 1 : 1;

        len = max(len, max(f[i], g[i]));
    }

    return len;
}

int main()
{
    maxTurbulenceSize({ 9,4,2,10,7,8,8,1,9 });
	return 0;
}